From ce2d69d2057a8aa10025c6be89c57f05fb5c4265 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Tue, 25 Jul 2017 15:36:42 -0400 Subject: [PATCH] nonzero exit code if some crates didn't install --- src/cargo/ops/cargo_install.rs | 10 +++++++--- tests/install.rs | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 96a739ac6..d8c8711b3 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -63,10 +63,10 @@ pub fn install(root: Option<&str>, let root = resolve_root(root, opts.config)?; let map = SourceConfigMap::new(opts.config)?; - let installed_anything = if krates.len() <= 1 { + let (installed_anything, scheduled_error) = if krates.len() <= 1 { install_one(root.clone(), map, krates.into_iter().next(), source_id, vers, opts, force, true)?; - true + (true, false) } else { let mut succeeded = vec![]; let mut failed = vec![]; @@ -95,7 +95,7 @@ pub fn install(root: Option<&str>, opts.config.shell().status("\nSummary:", summary.join(" "))?; } - !succeeded.is_empty() + (!succeeded.is_empty(), !failed.is_empty()) }; if installed_anything { @@ -114,6 +114,10 @@ pub fn install(root: Option<&str>, dst.display()))?; } + if scheduled_error { + bail!("some crates failed to install"); + } + Ok(()) } diff --git a/tests/install.rs b/tests/install.rs index bd4b20a63..9d385551b 100644 --- a/tests/install.rs +++ b/tests/install.rs @@ -60,7 +60,7 @@ fn multiple_pkgs() { pkg("bar", "0.0.2"); assert_that(cargo_process("install").args(&["foo", "bar", "baz"]), - execs().with_status(0).with_stderr(&format!("\ + execs().with_status(101).with_stderr(&format!("\ [UPDATING] registry `[..]` [DOWNLOADING] foo v0.0.1 (registry file://[..]) [INSTALLING] foo v0.0.1 @@ -76,6 +76,7 @@ error: could not find `baz` in `registry [..]` Summary: Successfully installed foo, bar! Failed to install baz (see error(s) above). warning: be sure to add `[..]` to your PATH to be able to run the installed binaries +error: some crates failed to install ", home = cargo_home().display()))); assert_that(cargo_home(), has_installed_exe("foo")); -- 2.30.2